package com.shop.controller;

import com.shop.feign.SeckillCouponFeign;
import com.shop.service.SeckillService;
import com.shop.to.SeckillRedisTo;
import com.shop.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/seckill")
public class SeckillController {
@Autowired
     private SeckillService seckillService;
    @GetMapping("/test1")
    public String test1(){
        seckillService.uploadSeckillSkuLatest3Ddays();
        return "123";
    }
//返回当前时间可以参与秒杀的商品信息
@GetMapping("/currentSeckillSkus")
    public R getCurrentSeckillSkus(){
    List<SeckillRedisTo> vos=seckillService.getCurrentSeckillSkus();
        return R.ok().data(vos);
    }

    /*
     * @Description 根据skuid来查询当前skuid下的秒杀信息
     * @param skuId
     * @return com.shop.utils.R
     * @author liusupeng
     * @date 2020/11/26 9:44
     */
@GetMapping("/getSeckillBySkuId/{skuId}")
    public R getSeckillBySkuId(@PathVariable("skuId") Long skuId){

        return R.ok().data(seckillService.getSeckillRedisBySkuId(skuId));
    }

}
